<?PHP
if ($vbulletin->options['neots_enable_product'] AND $vbulletin->options['neots_postbit_display']) {
	$useronline = 0;
	$neots_online = '<dt>Teamspeak Status</dt><dd>Offline</dd>';
	$post['neots_uid'] = unserialize($post['neots_uid']);
	if (is_array($post['neots_uid'])) {
		/* load framework library */
		require_once("./teamspeak/TeamSpeak3.php");
		/* initialize */
		TeamSpeak3::init();
		$ts3_VirtualServer = TeamSpeak3::factory("serverquery://".$vbulletin->options['neots_uname'].":".$vbulletin->options['neots_pass']."@".$vbulletin->options['neots_ip'].":".$vbulletin->options['neots_port']."/?server_port=".$vbulletin->options['neots_id']);
		try {
			foreach ($post['neots_uid'] as $uid) {
				$filter = array("client_unique_identifier" => $uid,"client_type" => TeamSpeak3::CLIENT_TYPE_REGULAR,);
				$clist = $ts3_VirtualServer->clientList($filter);
				foreach ($clist as $client) {
					$useronline = $useronline+1;
					if ($onlinenames) {
						$onlinenames = $onlinenames.', '.$client['client_nickname'];
					}
					else {
						$onlinenames = $client['client_nickname'];
					}
				}
			}
		}
		catch(Exception $e) {
		}
	}
	else {
		$useronline = -1;
	}
	if ($useronline >= 1) {
		$neots_online = '<dt>TS Status</dt><dd>Online with '.$useronline.' client(s)</dd><dt>TS Nicks</dt><dd>'.$onlinenames.'</dd>';
	}
	elseif ($useronline = 0) {
		$neots_online = '<dt>Teamspeak Status</dt><dd>Offline</dd>';
	}
	else {
		$neots_online = ''/*'<dt>Teamspeak Status</dt><dd>N/A</dd>'*/;
	}
$template_hook['postbit_userinfo_right_after_posts'] .= $neots_online;
}
?>